<?php
/**
 * <https://y.st./>
 * Copyright © 2019 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => 'They shipped it.',
	'takedown' => '2017-11-01',
	'<{body}>' => <<<END
<img src="/img/CC_BY-SA_4.0/y.st./weblog/2019/08/09.jpg" alt="Roadwork" class="framed-centred-image" width="800" height="480"/>
<section id="dreams">
	<h2>Dream journal</h2>
	<p>
		I dreamed I was playing Minetest, and I&apos;d reached this one island quite a while ago.
		I&apos;d set up roads and buildings.
		I noticed some grass, and realised that it had been staring me in the face and I&apos;d just passed it by.
		I could have had a wheat farm by now, but I&apos;d forgotten somehow that grass drops wheat seeds, so I&apos;d left it alone.
	</p>
</section>
<section id="diet">
	<h2>Dietary intake</h2>
	<p>
		I had 81 grams of cereal and 129 grams of soy milk for breakfast.
		I sort of started stress-eating though, and had 313 grams of pretzels.
		I tried to compensate by skipping lunch.
		For dinner, I had a veggie patty, tapioca cheese, and pickle sandwich.
	</p>
</section>
<section id="bicycle">
	<h2>Bicycle maintenance</h2>
	<p>
		I&apos;ve been meaning to oil my bike for quite a while.
		I&apos;ve had the oil even, just not a good way to apply it.
		What I needed was an oil can.
		I was waiting for the local hardware store to switch their sales to something favourable to get one though.
		They&apos;ve got this gimmick where you use these coupons to get gratis items with every purchase, and which items youcan choose from depends on their current sales.
		They haven&apos;t had any gratis items I&apos;ve needed lately though.
	</p>
	<p>
		However, my bike was creaking really badly on the way to the $a[EUGLUG] meeting and back last night.
		It was way past time to get the bike oiled, so this morning, I went out and got that oil can.
		The oil cleared up the squeaking I&apos;ve been meaning to take care of for a while now.
		However, it didn&apos;t fix the creaking, or the feeling of instability I detect in the peddles through my feet.
		Something else is wrong.
		If anything, the oil cleared up the surface problems so I could feel the worse problems more clearly.
		It feels like the axil the peddles are connected to is where the instability lies.
	</p>
</section>
<section id="drudgery">
	<h2>Drudgery</h2>
	<p>
		My discussion post for the day:
	</p>
	<blockquote>
		<p>
			Most of the time, our computer&apos;s aren&apos;t able to actually display {$a['3D']} images.
			That&apos;s fine, because we can&apos;t actually see in {$a['3D']} either.
			Instead, we see a {$a['2D']} perspective of our {$a['3D']} world.
			As such, it&apos;s fine for computers to render in {$a['2D']} in nearly every situation.
		</p>
		<p>
			Ray-casting and ray-tracing are a couple different ways to convert {$a['3D']} scenes into {$a['2D']} images for display.
			Unfortunately, &quot;ray-casting&quot; and &quot;ray-tracing&quot; aren&apos;t very concrete terms, and can mean different things depending on who you talk to (Cunningham, 2003).
		</p>
		<h3>Ray-casting</h3>
		<p>
			Cunningham defines ray-casting as sending a number of rays out from the camera position through the scene, one ray for each pixel, and using the colour of the closest surface each ray collides with as the colour of the corresponding pixel.
			Ray-casting is a very simple model, and isn&apos;t able to account for things such as shadows, reflections, or refraction of the light.
			First, clipping planes are optionally used, and the viewing area is divided up among the number of pixels the final image will have.
			For each of these sections, a ray is sent out through the scene, and collision detection algorithms are used to determine what objects are intersected with, and how far away they are.
			Any rays that don&apos;t hit anything will paint their corresponding pixel the colour of the background, while any rays that do come in contact with something from the scene will instead use the colour of the nearest thing to the camera that they intersected with.
			If lighting is used in the scene, lights will also need to be taken into account when setting the colour of the pixel for any ray that came in contact with an object (Cunningham, 2003).
		</p>
		<h3>Ray-tracing</h3>
		<p>
			By Cunningham&apos;s definition, ray tracing is any technique similar to ray-casting, but that uses shadows, reflections, light refraction, or multiple rays per image pixel (Cunningham, 2003).
			By that definition, ray-tracing is always more complex, and thus always more computationally expensive.
		</p>
		<h3>Lighting</h3>
		<p>
			When using ray-casting, lighting is only used to tell which faces of an object are exposed to the light.
			However, when you&apos;re rendering shadows, you have to do a bit more computation.
			For each light, you need to draw a ray from each point hit by one of the camera rays to each of the light sources.
			If the closest object the ray intersects isn&apos;t the light source itself, the object is in shadow as far as that light source is concerned, and receives none of that light source&apos;s light (Cunningham, 2003).
			Of course, the object could still receive light from another light source, which is why a ray to <strong>*each*</strong> light source is needed.
		</p>
		<h3>Reflection</h3>
		<p>
			Reflection, in {$a['3D']} graphics, is when light doesn&apos;t spread out in every direction from where it&apos;s transmitted from, but instead bounces at a particular angle.
			To find the vector representing the light after reflection, we plug the normal vector of the surface and the vector of the incoming light into an equation.
			We calculate the dot product of the two vectors, multiply the result by two times the normal vector, and subtract the result of that from the incoming vector (Cunningham, 2003).
		</p>
		<h3>Refraction</h3>
		<p>
			Refraction in {$a['3D']} graphics is similar to refraction in the real world.
			Light gets bent as it passes through transparent objects.
			In the real world, this happens because light travels at different speeds through different materials, and the measure of this speed for a given material is called the index of refraction.
			While light doesn&apos;t travel at any speed within a simulated scene, these indexes of refraction are still used to determine the angle the light gets bent at (Cunningham, 2003).
		</p>
		<h3>Primary and secondary rays</h3>
		<p>
			Primary rays are simply the rays sent out from the camera&apos;s perspective.
			They&apos;re the rays used in ray-casting.
			Ray-tracing uses these rays as well, but additionally uses secondary arrays.
			Secondary rays are used under certain circumstances when the primary rays come in contact with the geometry of the scene (Cunningham, 2003).
			For example, the reflected rays, refracted rays, and rays used to place shadows are all examples of secondary rays.
			With that in mind, another way to phrase Cunningham&apos;s separation between ray-casting and ray-tracing is that ray-casting doesn&apos;t use secondary rays, while ray-tracing does.
		</p>
		<div class="APA_references">
			<h3>References:</h3>
			<p>
				Cunningham, S.
				(2003).
				<a href="https://www.cs.csustan.edu/~rsc/NSF/Notes.pdf">Computer Graphics: Programming, Problem Solving, and Visual Communication</a>.
				Retrieved from <code>https://www.cs.csustan.edu/~rsc/NSF/Notes.pdf</code>
			</p>
		</div>
	</blockquote>
</section>
<section id="Minetest">
	<h2>Minetest</h2>
	<img src="/img/CC_BY-SA_3.0/minetest.net./weblog/2019/08/09.png" alt="An eerie door in the darkness" class="framed-centred-image" width="1024" height="600"/>
	<p>
		I set up ladders and a door back to the main path from that glitch-warp chamber in case I end up back there again.
		Keeping the door out of the light was preferable from the side of the tunnel, but made escape difficult from the side of the glitch-warp chamber.
		In the real world, light would easily hit the door from one side, getting blocked by the door, providing the effect that I was after.
		But Minetest isn&apos;t the real world.
		Nodes that don&apos;t take up the full space of a node have to have their <code>paramtype2</code> set to <code>&quot;light&quot;</code>.
		Otherwise, they&apos;re completely in shadow even with full light exposure.
		When <code>paramtype2</code> is set to <code>&quot;light&quot;</code>, <code>param2</code> is used to determine the lighting on the entire node.
		Different surfaces don&apos;t get different levels of light like they do for basic, full-sized nodes.
		I ended up compromising, and putting a torch in the chamber <strong>*just*</strong> barely within reach of the door, so the door is lit, but no light spills out into the tunnel.
		From the dark tunnel, the door to the glitch-warp chamber now eerily glows in the darkness.
	</p>
	<p>
		I&apos;ve come up with a new idea for dealing with my excess pine needles.
		If I set up my inventory just right, I can actually bind down both mouse buttons, and the machine will place and dig the same node repeatedly, moving on to the next node when the drop is achieved.
		I can eliminate several stacks of needles in my sleep that way.
		The trick is that I need to set my inventory up in such a way that it doesn&apos;t siphon the freshly-dug leaves away from my hand, so they get placed right back down, but any dropped saplings <strong>*do*</strong> get siphoned away, so I don&apos;t repeatedly dig and place a sapling.
		To do this, I make sure not to have any non-full stacks of needles in my main inventory, make sure my first inventory slot is empty, and set up several inventory slots each containing only one sapling.
		The game won&apos;t overfill stacks when digging, so the needles go to my first open slot, which I&apos;ve set to be the active hotbar slot.
		If there&apos;s a partial stack of something you newly get though, the game tries to put what you dug into that stack, so the saplings get pulled to the incomplete stacks.
		It&apos;s perfect, aside from that I have to save some slots to hold the needles I need to get back out of the mine.
		To get the most out of this technique, I&apos;d need to not build underground, but instead build my tower of needles up into the sky.
		I could set up a whopping thirty-one stacks of needles, plus one individual needle node if I wanted, all to be mined in my sleep.
		I don&apos;t want to do that right now though, as it&apos;d generate a bunch of unused sky space that then has to be stored for the rest of the life of this map.
		Once I&apos;ve got my needle count down for a first time, I won&apos;t even need all that space anyway, so it&apos;s not like this is sky space I&apos;d be continually using for this purpose, not to mention that I&apos;m trying to escape the island, so if I were to keep this up, I&apos;d need to generate another sky area elsewhere.
	</p>
	<p>
		I&apos;ll probably build a new mine, with powered rails as the main entry and exit method.
		To do that, I&apos;ll need the entrance to be at a forty-five degree angle, not straight down, so I can&apos;t really redo the entrance to the current mine without using a very distant location as the entry point.
	</p>
</section>
<section id="laser">
	<h2>Hair-removing $a[laser]</h2>
	<p>
		I received notification that the $a[laser] has been shipped this time.
		Awesome.
		Finally, this one&apos;s a package that should actually arrive.
		The estimated delivery time is ten days according to the email, so if that estimation is spot-on, I&apos;ll have the $a[laser] in hand the day before my next $a[laser] appointment.
		Ignoring the frustration of having wasted nearly a month for the last $a[laser] I ordered, I find having this one the day before my next treatment hilarious.
	</p>
</section>
END
);
